function getQueryString(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) return decodeURI(r[2]);
  return null;
}

function getSpaceId(gridName) {
  var item = $Config.SPACEID.find(n => n.spaceName == gridName);
  return (item && item.spaceId) || '';
}

var $Config = {
  dev: location.href.includes('localhost'),
  prodction: !location.href.includes('localhost'),

  APPNAME: '江阴市智慧城市综合管理平台',

  ZOOM: 11,
  ZOOM_2: 13.3,
  ZOOM_3: 15.32,
  CENTER: [120.29720306396486, 31.839065551757812],
  WGH_POLOGON_COLOR: [],
  SPACEID: parent.cityarea || [{"spaceName":"江阴市","spaceId":"gyqkj"}],
  DefaultSpaceId: 'gyqkj',
  prismClick: 'dblclick', // 网格块双击切换dblclick
  debug: true,
  VIDEO_CAMERA_URL:  'https://gyyth.spfw.05info.com:8442/gyyth/index.html?',
  ZOOMS: [3, 18],

  // L_MAP_EPSG: 'EPSG3857',
  // L_MAP_LngLat_SYS: 'GCJ02',
  // layerConfig: {
  //   url: [
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=img_c&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}',
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=vec_c&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}',
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=cva_c&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}'
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=vec_w&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}',
  //     (location.hostname.startsWith('172') ? 'http://172.19.141.135:8082' : 'http://121.229.49.56:8082') + '/googlemaps/satellite/{z}/{x}/{y}.jpg'
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=img_w&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}',
  //     // 'http://t0.tianditu.gov.cn/DataServer?T=cva_w&tk=c27c613115979d179e2794dcb248c29d&x={x}&y={y}&l={z}'
  //   ]
  // },
};

if (parent.$Config && parent.$Config.mapConfig) {
  $Config = _.extend($Config, parent.$Config.mapConfig);
}

var modules = {};


if (getQueryString('key')) {
  $Config = $.extend($Config, modules[getQueryString('key')]);
}

var mapMenuOptions = [{
  id: "population",
  name: "人",
  api: 'api/yth/wgh/population.jsp',
  loaded: false,
  show: true,
  childs: []
},
{
  id: "address",
  name: "地",
  api: 'api/yth/wgh/address.jsp',
  loaded: false,
  show: true,
  childs: []
},
{
  id: "events",
  name: "事",
  api: 'api/yth/wgh/events.jsp',
  loaded: false,
  show: false,
  childs: []
},
{
  id: "things",
  name: "物",
  api: 'api/yth/wgh/things.jsp',
  loaded: false,
  show: true,
  childs: []
},
{
  id: "organization",
  name: "组织",
  loaded: false,
  api: 'api/yth/wgh/organization.jsp',
  show: true,
  childs: []
}
];

var bottomMenus = {
  sjfx: [
    {name: '人口统计', icon: './static/imgs/sjfx/np_city_icon4.png', 
      subItems: [
        {name: '人口年度分析', url: './charts/rkndfx.html'},
        {name: '重点人群分析', url: './charts/zhongdianrenkou/jzry.html'},
        {name: '帮扶对象分析', url: './charts/rkndfx.html'},
        {name: '客流来源分析', url: './charts/rkndfx.html'},
        {name: '户籍人口统计', url: './charts/hjrk.html'}
      ]
    },
    {name: '经济运行', icon: './static/imgs/sjfx/np_city_icon5.png', subItems: [
      {name: '动态地区分析'},
      {name: '经济社会发展成果'},
      {name: '经济统计分析'},
      {name: '企业统计分析'}
    ]},
    {name: '事件统计', icon: './static/imgs/sjfx/np_city_icon6.png'},
    {name: '基础设施', icon: './static/imgs/sjfx/np_city_icon7.png', subItems: [
      {name: '城市部件'},
      {name: '视频设备'}
    ]},
    {name: '人文素质', icon: './static/imgs/sjfx/np_city_icon8.png', subItems: [
      {name: '文化程度分析'},
      {name: '学校分布'}
    ]},
    {name: '公共服务', icon: './static/imgs/sjfx/np_city_icon9.png', subItems: [
      {name: '水电煤'},
      {name: '居民就医'}
    ]},
    {name: '城市交通', icon: './static/imgs/sjfx/np_city_icon10.png', subItems: [
      {name: '交通路况'},
      {name: '交通出行'}
    ]},
    {name: '生活环境', icon: './static/imgs/sjfx/np_city_icon11.png', subItems: [
      {name: '空气质量'},
      {name: '水质量'},
      {name: '绿化指标统计'},
      {name: '城市绿化分布'},
      {name: '国家森林达标情况'}
    ]}
  ]
};
